package com.example.addanimotion;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.widget.Button;
import android.widget.LinearLayout;

public class ScaleButton extends Button {

	public ScaleButton(Context context) {
		super(context);
	}

	@Override
	public boolean onTouchEvent(MotionEvent event) {
	//Log.e("scale", this.get);
//    	try{
//    		((RelativeLayout)this.getParent()).invalidate();
//    	}catch (Exception e) {
//    		((GridLayout)this.getParent()).invalidate();
//		}
		switch (event.getAction()) {
		case KeyEvent.ACTION_DOWN:
			setScaleX(1.5f);
			setScaleY(1.5f);
			break;
		case KeyEvent.ACTION_UP:
			setScaleX(1.0f);
			setScaleY(1.0f);
			showLayout();
			break;
		}
		return super.onTouchEvent(event);
	}
	
	private void showLayout(){
    	this.bringToFront();
    	LinearLayout ll = (LinearLayout) this.getParent();
    	ll.invalidate();
    	int len = ll.getChildCount();
 /*   	for(int i=0; i<len; i++){
    		Button btn = (Button) ll.getChildAt(i);
    		btn.setText(String.valueOf(ll.indexOfChild(btn)));
    	}*/
	}

}
